<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<TITLE>
Rational (Metadata-Extractor - JavaDoc - An Open Source Java Library for Image File Metadata)
</TITLE>

<META NAME="keywords" CONTENT="com.drew.lang.Rational class">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    parent.document.title="Rational (Metadata-Extractor - JavaDoc - An Open Source Java Library for Image File Metadata)";
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Rational.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<a href='http://www.drewnoakes.com/code/exif/' title='Go to the project home page.'><img src='http://metadata-extractor.googlecode.com/git/Resources/metadata-extractor-logo-131x30.png' border=0 alt='Metadata Extractor Logo'></a></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../com/drew/lang/RandomAccessFileReader.html" title="class in com.drew.lang"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../com/drew/lang/StringUtil.html" title="class in com.drew.lang"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../index.html?com/drew/lang/Rational.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Rational.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.drew.lang</FONT>
<BR>
Class Rational</H2>
<PRE>
java.lang.Object
  <IMG SRC="../../../resources/inherit.gif" ALT="extended by ">java.lang.Number
      <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>com.drew.lang.Rational</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD>java.io.Serializable</DD>
</DL>
<HR>
<DL>
<DT><PRE>public class <B>Rational</B><DT>extends java.lang.Number<DT>implements java.io.Serializable</DL>
</PRE>

<P>
Immutable class for holding a rational number without loss of precision.  Provides
 a familiar representation via toString() in form <code>numerator/denominator</code>.
<P>

<P>
<DL>
<DT><B>Author:</B></DT>
  <DD>Drew Noakes http://drewnoakes.com</DD>
<DT><B>See Also:</B><DD><A HREF="../../../serialized-form.html#com.drew.lang.Rational">Serialized Form</A></DL>
<HR>

<P>

<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#Rational(long, long)">Rational</A></B>(long&nbsp;numerator,
         long&nbsp;denominator)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a new instance of Rational.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;byte</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#byteValue()">byteValue</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the specified number as a <code>byte</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;double</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#doubleValue()">doubleValue</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the specified number as a <code>double</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#equals(java.lang.Object)">equals</A></B>(java.lang.Object&nbsp;obj)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Compares two <code>Rational</code> instances, returning true if they are mathematically
 equivalent.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;float</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#floatValue()">floatValue</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the specified number as a <code>float</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#getDenominator()">getDenominator</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the denominator.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#getNumerator()">getNumerator</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the numerator.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/drew/lang/Rational.html" title="class in com.drew.lang">Rational</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#getReciprocal()">getReciprocal</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the reciprocal value of this object as a new Rational.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../com/drew/lang/Rational.html" title="class in com.drew.lang">Rational</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#getSimplifiedInstance()">getSimplifiedInstance</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 Simplifies the Rational number.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#hashCode()">hashCode</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#intValue()">intValue</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the specified number as an <code>int</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#isInteger()">isInteger</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Checks if this rational number is an Integer, either positive or negative.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;long</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#longValue()">longValue</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the specified number as a <code>long</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;short</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#shortValue()">shortValue</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the value of the specified number as a <code>short</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#toSimpleString(boolean)">toSimpleString</A></B>(boolean&nbsp;allowDecimal)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the simplest representation of this Rational's value possible.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.lang.String</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../com/drew/lang/Rational.html#toString()">toString</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a string representation of the object of form <code>numerator/denominator</code>.</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.Object</B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, finalize, getClass, notify, notifyAll, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="Rational(long, long)"><!-- --></A><H3>
Rational</H3>
<PRE>
public <B>Rational</B>(long&nbsp;numerator,
                long&nbsp;denominator)</PRE>
<DL>
<DD>Creates a new instance of Rational.  Rational objects are immutable, so
 once you've set your numerator and denominator values here, you're stuck
 with them!
<P>
</DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="doubleValue()"><!-- --></A><H3>
doubleValue</H3>
<PRE>
public double <B>doubleValue</B>()</PRE>
<DL>
<DD>Returns the value of the specified number as a <code>double</code>.
 This may involve rounding.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE>doubleValue</CODE> in class <CODE>java.lang.Number</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the numeric value represented by this object after conversion
         to type <code>double</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="floatValue()"><!-- --></A><H3>
floatValue</H3>
<PRE>
public float <B>floatValue</B>()</PRE>
<DL>
<DD>Returns the value of the specified number as a <code>float</code>.
 This may involve rounding.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE>floatValue</CODE> in class <CODE>java.lang.Number</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the numeric value represented by this object after conversion
         to type <code>float</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="byteValue()"><!-- --></A><H3>
byteValue</H3>
<PRE>
public final byte <B>byteValue</B>()</PRE>
<DL>
<DD>Returns the value of the specified number as a <code>byte</code>.
 This may involve rounding or truncation.  This implementation simply
 casts the result of <code>doubleValue()</code> to <code>byte</code>.
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>byteValue</CODE> in class <CODE>java.lang.Number</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the numeric value represented by this object after conversion
         to type <code>byte</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="intValue()"><!-- --></A><H3>
intValue</H3>
<PRE>
public final int <B>intValue</B>()</PRE>
<DL>
<DD>Returns the value of the specified number as an <code>int</code>.
 This may involve rounding or truncation.  This implementation simply
 casts the result of <code>doubleValue()</code> to <code>int</code>.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE>intValue</CODE> in class <CODE>java.lang.Number</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the numeric value represented by this object after conversion
         to type <code>int</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="longValue()"><!-- --></A><H3>
longValue</H3>
<PRE>
public final long <B>longValue</B>()</PRE>
<DL>
<DD>Returns the value of the specified number as a <code>long</code>.
 This may involve rounding or truncation.  This implementation simply
 casts the result of <code>doubleValue()</code> to <code>long</code>.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE>longValue</CODE> in class <CODE>java.lang.Number</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the numeric value represented by this object after conversion
         to type <code>long</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="shortValue()"><!-- --></A><H3>
shortValue</H3>
<PRE>
public final short <B>shortValue</B>()</PRE>
<DL>
<DD>Returns the value of the specified number as a <code>short</code>.
 This may involve rounding or truncation.  This implementation simply
 casts the result of <code>doubleValue()</code> to <code>short</code>.
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>shortValue</CODE> in class <CODE>java.lang.Number</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the numeric value represented by this object after conversion
         to type <code>short</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="getDenominator()"><!-- --></A><H3>
getDenominator</H3>
<PRE>
public final long <B>getDenominator</B>()</PRE>
<DL>
<DD>Returns the denominator.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="getNumerator()"><!-- --></A><H3>
getNumerator</H3>
<PRE>
public final long <B>getNumerator</B>()</PRE>
<DL>
<DD>Returns the numerator.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="getReciprocal()"><!-- --></A><H3>
getReciprocal</H3>
<PRE>
public <A HREF="../../../com/drew/lang/Rational.html" title="class in com.drew.lang">Rational</A> <B>getReciprocal</B>()</PRE>
<DL>
<DD>Returns the reciprocal value of this object as a new Rational.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>the reciprocal in a new object</DL>
</DD>
</DL>
<HR>

<A NAME="isInteger()"><!-- --></A><H3>
isInteger</H3>
<PRE>
public boolean <B>isInteger</B>()</PRE>
<DL>
<DD>Checks if this rational number is an Integer, either positive or negative.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="toString()"><!-- --></A><H3>
toString</H3>
<PRE>
public java.lang.String <B>toString</B>()</PRE>
<DL>
<DD>Returns a string representation of the object of form <code>numerator/denominator</code>.
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE></DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>a string representation of the object.</DL>
</DD>
</DL>
<HR>

<A NAME="toSimpleString(boolean)"><!-- --></A><H3>
toSimpleString</H3>
<PRE>
public java.lang.String <B>toSimpleString</B>(boolean&nbsp;allowDecimal)</PRE>
<DL>
<DD>Returns the simplest representation of this Rational's value possible.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="equals(java.lang.Object)"><!-- --></A><H3>
equals</H3>
<PRE>
public boolean <B>equals</B>(java.lang.Object&nbsp;obj)</PRE>
<DL>
<DD>Compares two <code>Rational</code> instances, returning true if they are mathematically
 equivalent.
<P>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>equals</CODE> in class <CODE>java.lang.Object</CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>obj</CODE> - the Rational to compare this instance to.
<DT><B>Returns:</B><DD>true if instances are mathematically equivalent, otherwise false.  Will also
         return false if <code>obj</code> is not an instance of <code>Rational</code>.</DL>
</DD>
</DL>
<HR>

<A NAME="hashCode()"><!-- --></A><H3>
hashCode</H3>
<PRE>
public int <B>hashCode</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Overrides:</B><DD><CODE>hashCode</CODE> in class <CODE>java.lang.Object</CODE></DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>

<A NAME="getSimplifiedInstance()"><!-- --></A><H3>
getSimplifiedInstance</H3>
<PRE>
public <A HREF="../../../com/drew/lang/Rational.html" title="class in com.drew.lang">Rational</A> <B>getSimplifiedInstance</B>()</PRE>
<DL>
<DD><p>
 Simplifies the Rational number.</p>
 <p>
 Prime number series: 1, 2, 3, 5, 7, 9, 11, 13, 17</p>
 <p>
 To reduce a rational, need to see if both numerator and denominator are divisible
 by a common factor.  Using the prime number series in ascending order guarantees
 the minimum number of checks required.</p>
 <p>
 However, generating the prime number series seems to be a hefty task.  Perhaps
 it's simpler to check if both d & n are divisible by all numbers from 2 ->
 (Math.min(denominator, numerator) / 2).  In doing this, one can check for 2
 and 5 once, then ignore all even numbers, and all numbers ending in 0 or 5.
 This leaves four numbers from every ten to check.</p>
 <p>
 Therefore, the max number of pairs of modulus divisions required will be:</p>
 <code><pre>
    4   Math.min(denominator, numerator) - 1
   -- * ------------------------------------ + 2
   10                    2
 <p/>
   Math.min(denominator, numerator) - 1
 = ------------------------------------ + 2
                  5
 </pre></code>
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>

<DT><B>Returns:</B><DD>a simplified instance, or if the Rational could not be simplified,
         returns itself (unchanged)</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Rational.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
<a href='http://www.drewnoakes.com/code/exif/' title='Go to the project home page.'><img src='http://metadata-extractor.googlecode.com/git/Resources/metadata-extractor-logo-131x30.png' border=0 alt='Metadata Extractor Logo'></a></EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../com/drew/lang/RandomAccessFileReader.html" title="class in com.drew.lang"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../com/drew/lang/StringUtil.html" title="class in com.drew.lang"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../index.html?com/drew/lang/Rational.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="Rational.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>
<i>Copyright &#169; 2003-2012 Drew Noakes. All Rights Reserved.</i>
<script src='http://www.google-analytics.com/urchin.js' type='text/javascript'></script>
<script type='text/javascript'>
_uacct = 'UA-936661-1';
urchinTracker();
</script>
</BODY>
</HTML>
